package cn.chinaunicom.smart.community.generator.rest;

//import cn.chinaunicom.fast.common.utils.Result;
import cn.chinaunicom.smart.community.generator.entity.GeneratorConfig;
import cn.chinaunicom.smart.community.generator.service.IGeneratorConfigService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author MrBird
 */
@Slf4j
@RestController
@RequestMapping("generatorConfig")
public class GeneratorConfigController {

    @Autowired
    private IGeneratorConfigService generatorConfigService;

//    @GetMapping
//    public Result getGeneratorConfig() {
//        return Result.success(generatorConfigService.findGeneratorConfig());
//    }

    @PostMapping
    @ApiOperation(value = "修改生成代码配置", notes = "修改生成代码配置")
    @ApiImplicitParam(name = "updateGeneratorConfig", value = "修改生成代码配置", required = true, dataType = "updateGeneratorConfig")
    public void updateGeneratorConfig(@Valid GeneratorConfig generatorConfig) throws Exception {
        if (StringUtils.isBlank(generatorConfig.getId())) {
            throw new Exception("配置id不能为空");
        }
        this.generatorConfigService.updateGeneratorConfig(generatorConfig);
    }
}
